﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<Section>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
<% this.Title = JSC.Portal.Web.App.Resources.Msg.SectionManagement;  %>
<script type="text/javascript">
    $(function() {
        $("#ValidFrom").datepicker($.extend({}, $.datepicker.regional["nl"], { showStatus: true, showOn: "both" }));
        $("#ValidTill").datepicker($.extend({}, $.datepicker.regional["nl"], { showStatus: true, showOn: "both" }));
        $("#gridpermissions").flexigrid({
            usepager: false, title: "<%= JSC.Portal.Web.App.Resources.Msg.Sections %>", useRp: false
        });
    });

    $(document).ready(function() {
        $("#formulier").validate(
        {
            rules:
            {
                Name: "required",
                Placeholder: "required",
                ModuleType: "required",
                ValidFrom: "required"
            },
            messages:
            {
                Name: "*",
                Placeholder: "*",
                ModuleType: "*",
                ValidFrom: "*"
            }
        });
        GetDynamicModulesProperties();
    });
 
    function GetDynamicModulesProperties() {
        var selectedValue = $("#ModuleType option:selected").val();
        var renderContainer = $("#modulesettings");
        if (selectedValue != '') {
            var url = '/portal/<%= ControllerNames.SECTIONS_CONTROLLER %><%= SiteSettings.APP_EXTENSION %>/GetModuleProperties/<%= ViewData.Model.Id %>?moduleTypeId=' + selectedValue;
            $.get(url, function(data) {
                renderContainer.html(data);
                renderContainer.fadeIn('slow');
            });
        }
        else {
            renderContainer.html('');
        }
    }

    function Delete() {
        if (confirm('<%= JSC.Portal.Web.App.Resources.Msg.AreYouSureYouWantToDeleteThis %>')) {
            window.location = '<%= Url.Action("Delete", new { id = ViewData.Model.Id }) %>';
        }
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="formulier" method="post" action="<%= Url.Action("SaveOrUpdate", new { id = ViewData.Model.Id }) %>">
    <%= Html.Hidden("portalpageid", ViewData.Model.Page.Id) %>
    <fieldset class="contentfieldset">
        <legend><%= JSC.Portal.Web.App.Resources.Msg.General %></legend>
        <table border="0">
            <% Html.RenderPartial("DescriptiveEntityEditControl"); %>
            <tr>
                <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.ShowName %></td>
                <td><%= Html.CheckBoxFor(model => model.ShowName) %></td>
            </tr>
            <tr>
                <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.Placeholder %></td>
                <td><%= Html.DropDownListFor(model => model.Placeholder, (SelectList)ViewData["Placeholders"], JSC.Portal.Web.App.Resources.Msg.PleaseMakeAChoice)%></td>
            </tr>          
            <% Html.RenderPartial("ValidEditControl"); %>
        </table>
    </fieldset>
    <fieldset class="contentfieldset">
        <legend><%= JSC.Portal.Web.App.Resources.Msg.Module %></legend>
        <table border="0">
            <tr>
                <td class="tdCaption"><%= JSC.Portal.Web.App.Resources.Msg.ModuleType %></td>
                <td> <% var test = new Dictionary<string, object>(); test.Add("onchange", "GetDynamicModulesProperties()"); %>
                <%= Html.DropDownListFor(model => model.ModuleType.Id, (SelectList)ViewData["ModuleTypes"], JSC.Portal.Web.App.Resources.Msg.PleaseMakeAChoice, test) %></td> 
            </tr>
            <tbody id="modulesettings">
            
            </tbody>
        </table>
    </fieldset>
    <br />  
    <% Html.RenderPartial("PermissionsEditControl"); %>
    <div class="button-bar-right">
        <%= Html.LinkButtonRight(JSC.Portal.Web.App.Resources.Msg.Cancel, Url.Action("Edit", ControllerNames.PORTALPAGES_CONTROLLER, new { id = ViewData.Model.Page.Id }))%>
        <%= Html.SeperatorRight() %>
        <% if (ViewData.Model.CanDelete) { %>
        <%= Html.LinkButtonRight(JSC.Portal.Web.App.Resources.Msg.Delete, "javascript:Delete()")%>
        <% } %>
        <%= Html.SeperatorRight() %>
        <%= Html.SubmitButtonRight(JSC.Portal.Web.App.Resources.Msg.Save)%>
    </div>
</form>
</asp:Content>
